<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <div th:replace="config :: copy"></div>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend th:if="${flag} eq 'edit'">编辑用户</legend>
    <legend th:if="${flag} eq 'add'">添加用户</legend>
</fieldset>
<form class="layui-form" th:action="@{saveEdit}" th:object="${user}" id="userEditSubmit">
    <div class="layui-form-item">
        <input type="hidden" name="id" th:value="${user.id}"/>
        <input type="hidden" name="flag" th:value="${flag}"/>
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-block">
            <input type="text" name="userName" lay-verify="required" autocomplete="off" class="layui-input" th:value="${user.userName}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-block">
            <input type="text" name="password" lay-verify="required" autocomplete="off" class="layui-input" th:value="${user.password}"/>
        </div>
    </div>
    <div class="layui-input-block">
        <button class="layui-btn" id="userEditBtn"  lay-submit="" lay-filter="userEdit">立即提交</button>
        <div class="layui-btn layui-btn-primary" onclick="closeEdit()">关闭</div>
    </div>
</form>


<script>
//    onclick="submitUserEdit()"
//    function submitUserEdit(){
//        parent.layer.load(2);
//        $('#userEditSubmit').submit();
//        parent.layer.closeAll('loading');
//    }

    function closeEdit(){
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

    layui.use(['form'],function(){
        var form = layui.form;
        form.on('submit(userEdit)',function(data){

        });
    })

</script>

</body>
</html>